using Network;

namespace LuaFramework
{

    public class NetworkManager : Manager
    {
        public TcpChannel tcpChannel;
        public KcpChannel kcpChannel;

        #region Unity lifecycle
        protected override void Start()
        {
            tcpChannel = new TcpChannel();
            kcpChannel = new KcpChannel();
        }

        protected override void Update()
        {
            tcpChannel.Tick(UnityEngine.Time.deltaTime);
            kcpChannel.Tick(UnityEngine.Time.deltaTime);
        }

        void OnDestroy()
        {
            TcpClose(); 
        }
        #endregion

        #region tcp
        public void TcpConnect(string host, int port)
        {
            tcpChannel.Connect(host, port);
        }

        public void TcpClose()
        {
            tcpChannel.Close();
            
        }
        #endregion

        #region kcp
        public void KcpConnect(string host, ushort port, uint conv)
        {
            kcpChannel.Connect(host, port, conv);
        }

        public void KcpClose()
        {
            kcpChannel.Close();

        }
        #endregion
    }

}
